package com.huonan.jb.treads;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPool  {

    public static ThreadPoolExecutor getExecutorService() {
        ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
                .setNameFormat("demo-pool-%d").build();

        //Common Thread Pool
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(6, 6,
                5, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<Runnable>(1000), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
        return threadPoolExecutor;
    }
}